import Router from "vue-router";
import Vue from "vue";
Vue.use(Router);

const routes = [
  {
    path: "/",
    redirect: "/product/list",
    // component: () => import("@/views/product/index.vue")
  },
  {
    path: "/product",
    component: () => import("@/views/product/index.vue"),
    redirect: "/product/list",
    children: [
      {
        path: "list",
        // 缓存次组件
        meta: {
          keepAlive: true,
          tittle: '列表'
        },
        component: () => import("@/views/product/children/list2.vue"),
      },
      {
        path: "detail/:productId",
        component: () => import("@/views/product/children/detail.vue"),
      },
    ],
  },
  { path: "/cart", component: () => import("@/views/cart/index.vue") },
  {
    path: "/my",
    component: () => import("@/views/my/index"),
    redirect: "/my/center",
    children: [
      {
        path: "center",
        component: () => import("@/views/my/children/center"),
      },
      {
        path: "set",
        component: () => import("@/views/my/children/set"),
      },
    ],
  },
  { path: "/type", component: () => import("@/views/type/index.vue") },
  {
    path: "/order",
    component: () => import("@/views/order/index.vue"),
    children: [
      { path: "list", component: () => import("@/views/order/children/list") },
     
      {
        path: "verify",  // 确定订单
        component: () => import("@/views/order/children/verify"), 
      }, 
      {
        path: "pay",  // 支付
        name: 'pay',
        component: () => import("@/views/order/children/pay"), 
      }, 
    ],
  },
  { path: "/login", component: () => import("@/views/account/index.vue") },
  { path: "/demo", component: () => import("@/views/demo/index.vue") }, 
];
 
const router = new Router({
  // mode:'history',
  scrollBehavior: () => ({
    y: 0
  }),
  routes, 
});

export default router;
